/*
 * @Descripttion: 
 * @version: 
 * @Author: wtzhang
 * @Date: 2021-07-06 08:57:37
 * @LastEditors: wtzhang
 * @LastEditTime: 2021-07-06 14:56:22
 */
(function () {
  
  console.log("********************* super关键字 *********************");
  
  class Animal {
    name: string;
    constructor(name:string) {
      this.name = name;
    }
    sayHello() {
      console.log(`${this.name}说：你好啊`);
    }
  }

  // Dog类继承父类
  class Dog extends Animal {
    age: number;
    constructor(name:string, age: number) {
      // 如果在子类中写了构造函数(constructor)，在子类构造函数中必须对父类进行调用
      super(name) // 使用super关键字调用父类，调用时父类有属性name，这里必须入参
      this.age = age
    }
  }
  const dog = new Dog('小黑', 18)
  console.log(dog.age);
  dog.sayHello()

})()